home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / sstream.cc < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  19.4 KB  |  787 lines

  1. #ifndef __SSTREAM_CC
  2. #define __SSTREAM_CC
  3. #pragma option push -b -a4 -Vx- -Ve- -w-inl -w-aus -w-sig
  4.  
  5. /***************************************************************************
  6.  *
  7.  * sstream.cc - Declarations for the Standard Library basic strings
  8.  *
  9.  * $Id: sstream.cc,v 1.54 1996/09/11 00:28:19 smithey Exp $
  10.  *
  11.  ***************************************************************************
  12.  *
  13.  * (c) Copyright 1994, 1995 Rogue Wave Software, Inc.
  14.  * ALL RIGHTS RESERVED *
  15.  * The software and information contained herein are proprietary to, and
  16.  * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
  17.  * intends to preserve as trade secrets such software and information.
  18.  * This software is furnished pursuant to a written license agreement and
  19.  * may be used, copied, transmitted, and stored only in accordance with
  20.  * the terms of such license and with the inclusion of the above copyright
  21.  * notice.  This software and information or any other copies thereof may
  22.  * not be provided or otherwise made available to any other person.
  23.  *
  24.  * Notwithstanding any other lease or license that may pertain to, or
  25.  * accompany the delivery of, this computer software and information, the
  26.  * rights of the Government regarding its use, reproduction and disclosure
  27.  * are as set forth in Section 52.227-19 of the FARS Computer
  28.  * Software-Restricted Rights clause.
  29.  * 
  30.  * Use, duplication, or disclosure by the Government is subject to
  31.  * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
  32.  * Technical Data and Computer Software clause at DFARS 252.227-7013.
  33.  * Contractor/Manufacturer is Rogue Wave Software, Inc.,
  34.  * P.O. Box 2328, Corvallis, Oregon 97339.
  35.  *
  36.  * This computer software and information is distributed with "restricted
  37.  * rights."  Use, duplication or disclosure is subject to restrictions as
  38.  * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
  39.  * Computer Software-Restricted Rights (April 1985)."  If the Clause at
  40.  * 18-52.227-74 "Rights in Data General" is specified in the contract,
  41.  * then the "Alternate III" clause applies.
  42.  *
  43.  **************************************************************************/
  44.  
  45. #ifndef _RWSTD_NO_NAMESPACE
  46. namespace std {
  47. #endif
  48.  
  49. /*
  50.  * basic_stringbuf(basic_ios::openmode)
  51.  */
  52.  
  53. template<class charT, class traits, class Allocator>
  54. basic_stringbuf<charT, traits, Allocator>::
  55. basic_stringbuf( ios_base::openmode which)
  56. : basic_streambuf<charT, traits>()
  57. , data_(0)
  58. , length_(0)
  59. , end_pos(0)
  60. {
  61.   setp(0,0);
  62.   setg(0,0,0);
  63.   basic_streambuf<charT,traits>::mode_ = which;
  64. }
  65.  
  66. /*
  67.  * basic_stringbuf(const basic_string, ios_base::openmode)
  68.  */
  69.  
  70. template<class charT, class traits, class Allocator>
  71. basic_stringbuf<charT, traits, Allocator>::
  72. basic_stringbuf(const string_type& s, ios_base::openmode which)
  73. : basic_streambuf<charT, traits>()
  74. , length_(s.length())
  75. {
  76.   basic_streambuf<charT,traits>::mode_ = which;
  77.  
  78.   data_ = new charT[length_];
  79.  
  80.   if(s.data())
  81.     traits::copy(data_, s.data(), length_);
  82.  
  83.   if(which & ios_base::in)
  84.     setg(data_, data_, data_+length_);
  85.  
  86.   if(which & ios_base::out)
  87.     setp(data_, data_+length_);
  88.  
  89.   if(which & ( ios_base::app | ios_base::ate ) )
  90.     pbump(length_);
  91.  
  92.   end_pos = length_;
  93.  
  94. }
  95.  
  96. /*
  97.  * virtual ~basic_stringbuf()
  98.  */
  99.  
  100. template<class charT, class traits, class Allocator>
  101. basic_stringbuf<charT, traits, Allocator>::~basic_stringbuf()
  102. {
  103.   if ( data_ )
  104.    delete [] data_;
  105. }
  106.  
  107.  
  108. /*
  109.  * basic_string str() const
  110.  */
  111.  
  112. template<class charT, class traits, class Allocator>
  113. basic_string<charT, traits, Allocator>
  114. basic_stringbuf<charT, traits, Allocator>::str() const
  115. {
  116.  
  117.   if ( end_pos == 0 )  return string_type();
  118.  
  119.   if ( (end_pos > ( pptr() - pbase() )) && (end_pos > ( egptr() - eback() )) )
  120.    return string_type(data_, end_pos);
  121.   else 
  122.    {
  123.       if ( ( pptr() - pbase() ) > ( egptr() - eback() ) )
  124.        return string_type(data_, pptr() - pbase() );
  125.       else
  126.        return string_type(data_, egptr() - eback() );
  127.    }
  128.    
  129. }
  130.  
  131. /*
  132.  * void str(const basic_string&)
  133.  */
  134.  
  135. template<class charT, class traits, class Allocator>
  136. void 
  137. basic_stringbuf<charT, traits, Allocator>::
  138. str(const string_type& s)
  139. {
  140.   if ( data_ )
  141.    delete [] data_;
  142.   length_ = s.length();
  143.  
  144.   if(length_ == 0) {
  145.     setg(0,0,0);
  146.     setp(0,0);
  147.     return;
  148.   }
  149.  
  150.   data_ = new charT[length_];
  151.  
  152.   if(s.data())
  153.     traits::copy(data_, s.data(), length_);
  154.     
  155.   if(basic_streambuf<charT,traits>::mode_ & ios_base::in)
  156.     setg(data_, data_, data_+length_);
  157.  
  158.   if(basic_streambuf<charT,traits>::mode_ & ios_base::out)
  159.    {
  160.     setp(data_, data_+length_);
  161.     if( (basic_streambuf<charT,traits>::mode_ & ios_base::app) || (basic_streambuf<charT,traits>::mode_ & ios_base::ate ) )
  162.     this->pbump(length_); 
  163.    } 
  164.  
  165.   end_pos = pptr() - pbase();
  166. }
  167.  
  168.  
  169. /*
  170.  * int_type overflow(int_type)
  171.  */
  172.  
  173. template<class charT, class traits, class Allocator>
  174. _TYPENAME basic_stringbuf<charT, traits, Allocator>::int_type
  175. basic_stringbuf<charT, traits, Allocator>::overflow(int_type c)
  176. {
  177.   if((basic_streambuf<charT,traits>::mode_ & ios_base::out) == 0) {
  178.     return traits::eof();
  179.   }
  180.   
  181.   charT        *temp;
  182.   int          old_numb_of_elements,new_numb_of_elements;
  183.   const int    increment=128;
  184.   int_type     var;
  185.  
  186.   if (pptr())
  187.     {
  188.        old_numb_of_elements = pptr() - data_;
  189.        
  190.        new_numb_of_elements = old_numb_of_elements + increment;
  191.  
  192.        temp = new charT[new_numb_of_elements];
  193.         
  194.        traits::copy(temp, data_, old_numb_of_elements);   
  195.  
  196.        setp (temp,temp+new_numb_of_elements);
  197.  
  198.        this->pbump(old_numb_of_elements);  
  199.  
  200.      
  201.        charT *tmp=temp+(gptr()-eback()); 
  202.        setg(temp, tmp, pptr()+1);
  203.  
  204.        delete [] data_;
  205.        
  206.        data_ = temp;
  207.      }
  208.    else
  209.      {
  210.         new_numb_of_elements=increment;
  211.  
  212.         temp = new charT[new_numb_of_elements];
  213.          
  214.         setp(temp,temp+new_numb_of_elements);
  215.  
  216.         if((basic_streambuf<charT,traits>::mode_ & ios_base::in) != 0)
  217.            setg(temp, temp , temp);
  218.  
  219.         data_ =temp; 
  220.      }
  221.   
  222.   if ( traits::eq_int_type(c,traits::eof()) ) var = traits::not_eof(c);
  223.   else
  224.    var = sputc(c);
  225.  
  226.   if ( (pptr() - pbase()) > end_pos )
  227.    end_pos = pptr() - pbase(); 
  228.  
  229.   return var;
  230. }
  231.  
  232. /*
  233.  * int_type pbackfail(int_type)
  234.  */
  235.  
  236. template<class charT, class traits, class Allocator>
  237. _TYPENAME basic_stringbuf<charT, traits, Allocator>::int_type
  238. basic_stringbuf<charT, traits, Allocator>::pbackfail(int_type c)
  239. {
  240.   
  241.    if ( (!traits::eq_int_type(c,traits::eof())) && (gptr()>eback()) )  {
  242.  
  243.                          if ( traits::eq(*(gptr()-1),traits::to_char_type(c)) ) 
  244.                                  {
  245.                                    this->gbump(-1);
  246.                                    return c;
  247.                                  }
  248.                                 else
  249.                                  {
  250.                                    if( basic_streambuf<charT,traits>::mode_ & ios_base::out )
  251.                                      {
  252.                                        this->gbump(-1);
  253.                                        *gptr()=traits::to_char_type(c);
  254.                                        return c;
  255.                                      }
  256.                                  }
  257.                  }    
  258.  
  259. if ( (traits::eq_int_type(c,traits::eof())) && (gptr()>eback()) )  { 
  260.                            this->gbump(-1);
  261.                                                    return traits::not_eof(c);
  262.                         }
  263.                                                 
  264.  
  265.   return traits::eof();
  266. }
  267.  
  268.  
  269. /*
  270.  * basic_streambuf<charT,traits>* setbuf(char_type* s, streamsize n)
  271.  */
  272.  
  273. template<class charT, class traits, class Allocator>
  274. basic_streambuf<charT, traits>*
  275. basic_stringbuf<charT, traits, Allocator>::setbuf(char_type* s, streamsize n)
  276. {
  277.  if((basic_streambuf<charT,traits>::mode_ & ios_base::out) != 0)
  278.   {
  279.     if ( n > ( pptr() - pbase() ) )
  280.      {
  281.        if ( s == 0 ) s = new charT[n];
  282.  
  283.          if ( s )
  284.           {
  285.             int          old_numb_of_elements;
  286.  
  287.             if (pptr())
  288.              {
  289.                old_numb_of_elements = pptr() - data_;
  290.         
  291.                traits::copy(s, data_, old_numb_of_elements);   
  292.  
  293.                setp (s,s+n-1);
  294.  
  295.                this->pbump(old_numb_of_elements);  
  296.  
  297.               charT *tmp=s+(gptr()-eback()); 
  298.               setg(s, tmp, pptr()+1);
  299.  
  300.               delete [] data_;
  301.        
  302.               data_ = s;
  303.              }
  304.             else
  305.              {
  306.          
  307.                setp(s,s+n-1);
  308.  
  309.                if((basic_streambuf<charT,traits>::mode_ & ios_base::in) != 0)
  310.                 setg(s, s , s);
  311.  
  312.                data_ =s; 
  313.               }
  314.            }
  315.           else
  316.            return (basic_streambuf<charT,traits>*)(0);
  317.  
  318.  
  319.      }
  320.     else
  321.      return (basic_streambuf<charT,traits>*)(0);
  322.   }
  323.  
  324.  return (basic_streambuf<charT,traits>*)(this);
  325. }
  326.  
  327.  
  328. /*
  329.  * int_type underflow()
  330.  */
  331.  
  332. template<class charT, class traits, class Allocator>
  333. _TYPENAME basic_stringbuf<charT, traits, Allocator>::int_type
  334. basic_stringbuf<charT, traits, Allocator>::underflow()
  335. {
  336.    if(gptr() && (gptr()<egptr()) ) return traits::to_int_type(*gptr());
  337.  
  338.  
  339.     if(((pptr() != 0) && ( (pptr() > egptr()) || ( end_pos > (egptr() - eback()) ) ) ) && (!gptr())) 
  340.       {
  341.         if ( end_pos > ( pptr() - pbase() ) )
  342.          setg(pbase(), pbase(), pbase()+end_pos );
  343.         else     
  344.          setg(pbase(), pbase(), pptr());
  345.         return traits::to_int_type(*gptr());
  346.       }
  347.      
  348.  
  349.  
  350.      if((pptr() != 0) && ( (pptr() > egptr()) || ( end_pos > ( egptr() - eback() )) ) ) 
  351.      {
  352.        if ( end_pos > ( pptr() - pbase() ) )
  353.         setg(eback(),gptr(),eback()+end_pos);
  354.        else
  355.         setg(eback(), gptr(), pptr());
  356.        return traits::to_int_type(*gptr());
  357.      }
  358.                                   
  359.   return traits::eof();
  360. }
  361.  
  362. /*
  363.  * pos_type seekoff(off_type, ios_base::seekdir, ios_base::openmode)
  364.  */
  365.  
  366. template<class charT, class traits, class Allocator>
  367. _TYPENAME basic_stringbuf<charT, traits, Allocator>::pos_type
  368. basic_stringbuf<charT, traits, Allocator>::
  369. seekoff(off_type off, ios_base::seekdir way, ios_base::openmode which)
  370. {
  371.   streamsize       newoff;
  372.   
  373.   if((which & ios_base::in) && (which & ios_base::out)) {
  374.      if ( (way==ios_base::beg) || (way==ios_base::end) )
  375.        {
  376.          if ( seekoff(off,way,ios_base::out) == pos_type(off_type(-1)) )
  377.           return pos_type(off_type(-1));
  378.          return seekoff(off,way,ios_base::in);
  379.        }
  380.      else
  381.        return pos_type(off_type(-1)); 
  382.   }
  383.   
  384.   if((which & ios_base::in) && (gptr()!=0)) {
  385.  
  386.     if ( (egptr() - eback()) > end_pos )
  387.      end_pos = egptr() - eback(); 
  388.  
  389.     if ( (pptr() - pbase()) > end_pos )
  390.      end_pos = pptr() - pbase(); 
  391.  
  392.     if(way == ios_base::beg)
  393.       newoff = 0;
  394.     if(way == ios_base::cur)
  395.       newoff = gptr() - eback();
  396.     if(way == ios_base::end)
  397.       newoff = end_pos;
  398.  
  399.     if ( newoff<0 )  return pos_type(off_type(-1)); 
  400.  
  401.      if ( ((eback()+long(newoff)+long(off))> egptr()) || ((newoff+off)< 0) )
  402.     return pos_type(-1);
  403.  
  404.       setg(eback(), eback() + long(newoff) + long(off), egptr());
  405.  
  406.     return pos_type(newoff+off);
  407.   }
  408.  
  409.  if((which & ios_base::in) && (gptr()==0) && (egptr()==0) && (eback()==0) ) 
  410.    return pos_type(0);
  411.  
  412.   if((which & ios_base::out) && (pptr()!=0) && !(basic_streambuf<charT,traits>::mode_ & ios_base::app) ) {
  413.  
  414.     if ( (egptr() - eback()) > end_pos )
  415.      end_pos = egptr() - eback(); 
  416.  
  417.     if ( (pptr() - pbase()) > end_pos )
  418.      end_pos = pptr() - pbase(); 
  419.  
  420.     if(way == ios_base::beg)
  421.       newoff = 0;
  422.     if(way == ios_base::cur)
  423.       newoff = pptr() - pbase();
  424.     if(way == ios_base::end)
  425.       newoff = end_pos;
  426.  
  427.     if ( (pptr() - pbase()) > end_pos ) end_pos = pptr() - pbase();
  428.  
  429.     if ( ((newoff+off)<0) || ((pbase()+long(newoff)+long(off))> epptr()) )
  430.     return pos_type(off_type(-1));   
  431.  
  432.     this->pbump( newoff+off-(pptr()-pbase())  );
  433.  
  434.     if ( gptr()<=pptr() )
  435.      setg(eback(),gptr(),pptr());
  436.     else
  437.      {
  438.        if ( (basic_streambuf<charT,traits>::mode_ & ios_base::out  ) &&
  439.           !(basic_streambuf<charT,traits>::mode_ & ios_base::in ) )
  440.         setg(pbase(),pptr(),epptr());
  441.      } 
  442.  
  443.     return pos_type(newoff+off);
  444.         
  445.    }
  446.    else 
  447.     {
  448.  
  449.      if ( basic_streambuf<charT,traits>::mode_ & ios_base::app )
  450.       return pos_type(pptr()-pbase());
  451.  
  452.      if((which & ios_base::out) && (pptr()==0) && (epptr()==0) && (pbase()==0) )
  453.       return pos_type(0);
  454.     }
  455.  
  456.  
  457.   return pos_type(off_type(-1));
  458. }
  459.  
  460. /*
  461.  * pos_type seekpos(pos_type, ios_base::openmode)
  462.  */
  463.  
  464. template<class charT, class traits, class Allocator>
  465. _TYPENAME basic_stringbuf<charT, traits, Allocator>::pos_type
  466. basic_stringbuf<charT, traits, Allocator>::
  467. seekpos(pos_type sp, ios_base::openmode which)
  468. {
  469.   streamsize    newoff = sp.offset();
  470.  
  471.    
  472.    if((which & ios_base::in) && (which & ios_base::out)) {
  473.          if ( seekpos(sp,ios_base::out) == pos_type(off_type(-1)) )
  474.           return pos_type(off_type(-1));
  475.          return seekpos(sp,ios_base::in);
  476.   }
  477.  
  478.   if((which & ios_base::in) && (gptr()!=0)) {
  479.     
  480.     if ( newoff<0 )  return pos_type(off_type(-1));
  481.     
  482.     if ( (eback()+long(newoff))> egptr() ) return pos_type(off_type(-1));
  483.  
  484.       setg(eback(), eback() + long(newoff), egptr());
  485.  
  486.     return pos_type(newoff);
  487.   }
  488.  
  489.  
  490.   if((which & ios_base::out) && (pptr()!=0) && !(basic_streambuf<charT,traits>::mode_ & ios_base::app) ) {
  491.  
  492.     if ( (newoff<0) || ((pbase()+long(newoff))> epptr()) )
  493.     return pos_type(off_type(-1)); 
  494.  
  495.     if ( (pptr() - pbase()) > end_pos ) end_pos = pptr() - pbase();
  496.  
  497.     this->pbump( newoff-(pptr()-pbase())  );
  498.  
  499.     if ( gptr()<=pptr() )
  500.      setg(eback(),gptr(),pptr());
  501.     else
  502.      {
  503.        if ( (basic_streambuf<charT,traits>::mode_ & ios_base::out  ) &&
  504.           !(basic_streambuf<charT,traits>::mode_ & ios_base::in ) )
  505.         setg(pbase(),pptr(),epptr());
  506.      }
  507.  
  508.     return pos_type(newoff);
  509.  
  510.    }
  511.   else 
  512.     if ( basic_streambuf<charT,traits>::mode_ & ios_base::app )
  513.      return pos_type(pptr()-pbase());
  514.  
  515.   return pos_type(off_type(-1));
  516.  
  517. }
  518.  
  519. /*
  520.  * streamsize xsputn(const char_type *, streamsize)
  521.  */
  522.  
  523. template<class charT, class traits, class Allocator>
  524. streamsize basic_stringbuf<charT, traits, Allocator>::
  525. xsputn(const char_type *s, streamsize n)
  526. {
  527.   if ( !s || (n == 0) ) return 0;
  528.  
  529.  if ( n > ( epptr()-pptr()+128 ) )
  530.  { 
  531.    if ( setbuf(0, pptr()-pbase()+n+128)== 0)
  532.     {
  533.       return 0;
  534.     }
  535.  
  536.   traits::copy(pptr(), s, n);
  537.   this->pbump(n);
  538.  }
  539.  else
  540.  {
  541.     int         i=0;
  542.  
  543.     while((i < n) && ( !traits::eq_int_type(sputc(*s++),traits::eof())))
  544.     i++;
  545.  
  546.     return i;
  547.  }
  548.  
  549.   return n;    
  550. }
  551.  
  552.  
  553.  
  554. /*
  555.  *
  556.  * class basic_istringstream
  557.  *
  558.  */
  559.  
  560. /*
  561.  * basic_istringstream(ios_base::openmode)
  562.  */
  563.  
  564. template<class charT, class traits, class Allocator>
  565. basic_istringstream<charT, traits, Allocator>::
  566. basic_istringstream(ios_base::openmode m)
  567. : basic_istream<charT, traits>( )
  568. , sb_(m | ios_base::in)
  569. {
  570.   init(&sb_);
  571. }
  572.  
  573. /*
  574.  * basic_istringstream(const basic_string<charT>&, ios_base::openmode)
  575.  */
  576.  
  577. template<class charT, class traits, class Allocator>
  578. basic_istringstream<charT, traits, Allocator>::
  579. basic_istringstream(const string_type& s, ios_base::openmode which)
  580. : basic_istream<charT, traits>( )
  581. , sb_(s, which | ios_base::in)
  582. {
  583.   init(&sb_);
  584. }
  585.  
  586. /*
  587.  * virtual ~basic_istringstream()
  588.  */
  589.  
  590. template<class charT, class traits, class Allocator>
  591. basic_istringstream<charT, traits, Allocator>::~basic_istringstream()
  592. {
  593.  
  594. }
  595.  
  596. /*
  597.  * basic_stringbuf *rdbuf() const
  598.  */
  599.  
  600. template<class charT, class traits, class Allocator>
  601. basic_stringbuf<charT, traits, Allocator> *
  602. basic_istringstream<charT, traits, Allocator>::rdbuf() const
  603. {
  604.   return (basic_stringbuf<charT, traits, Allocator> *)&sb_;
  605. }
  606.  
  607. /*
  608.  * basic_string<charT> str() const
  609.  */
  610.  
  611. template<class charT, class traits, class Allocator>
  612. basic_string<charT, traits, Allocator>
  613. basic_istringstream<charT, traits, Allocator>::str() const
  614. {
  615.   return sb_.str();
  616. }
  617.  
  618. /*
  619.  * void str(const basic_string<charT>& )
  620.  */
  621.  
  622. template<class charT, class traits, class Allocator>
  623. void basic_istringstream<charT, traits, Allocator>::str(const string_type& s)
  624. {
  625.   sb_.str(s);
  626. }
  627.  
  628. /*
  629.  *
  630.  *
  631.  * class basic_ostringstring
  632.  *
  633.  */
  634.  
  635. /*
  636.  * basic_ostringstream(ios_base::openmode)
  637.  */
  638.  
  639. template<class charT, class traits, class Allocator>
  640. basic_ostringstream<charT, traits, Allocator>::
  641. basic_ostringstream(ios_base::openmode w)
  642. : basic_ostream<charT, traits>( )        
  643. , sb_(w | ios_base::out )
  644. {
  645.    init(&sb_);
  646. }
  647.  
  648. /*
  649.  * basic_ostringstream(const basic_string&, ios_base::openmode)
  650.  */
  651.  
  652. template<class charT, class traits, class Allocator>
  653. basic_ostringstream<charT, traits, Allocator>::
  654. basic_ostringstream(const string_type& s, ios_base::openmode which)
  655. : basic_ostream<charT, traits>( )
  656. , sb_(s, which | ios_base::out )
  657. {
  658.   init(&sb_);
  659. }
  660.  
  661. /*
  662.  * virtual ~basic_ostringstream()
  663.  */
  664.  
  665. template<class charT, class traits, class Allocator>
  666. basic_ostringstream<charT, traits, Allocator>::~basic_ostringstream()
  667. {
  668.  
  669. }
  670.  
  671. /*
  672.  * basic_stringbuf *rdbuf() const
  673.  */
  674.  
  675. template<class charT, class traits, class Allocator>
  676. basic_stringbuf<charT, traits, Allocator> *
  677. basic_ostringstream<charT, traits, Allocator>::rdbuf() const
  678. {
  679.     return (basic_stringbuf<charT, traits, Allocator> *)&sb_;
  680. }
  681.  
  682. /*
  683.  * basic_string str() const
  684.  */
  685.  
  686. template<class charT, class traits, class Allocator>
  687. basic_string<charT, traits, Allocator>
  688. basic_ostringstream<charT, traits, Allocator>::str() const
  689. {
  690.   return sb_.str();
  691. }
  692.  
  693. /*
  694.  * void str(const basic_string& s)
  695.  */
  696.  
  697. template<class charT, class traits, class Allocator>
  698. void basic_ostringstream<charT, traits, Allocator>::
  699. str(const string_type& s)
  700. {
  701.   sb_.str(s);
  702. }
  703.  
  704. /*
  705.  *
  706.  *
  707.  * class basic_stringstream
  708.  *
  709.  */
  710.  
  711. /*
  712.  * basic_stringstream(ios_base::openmode)
  713.  */
  714.  
  715. template<class charT, class traits, class Allocator>
  716. basic_stringstream<charT, traits, Allocator>::
  717. basic_stringstream(ios_base::openmode w)
  718. : basic_iostream<charT, traits>( )        
  719. , sb_(w)
  720. {
  721.    init(&sb_);
  722. }
  723.  
  724. /*
  725.  * basic_stringstream(const basic_string&, ios_base::openmode)
  726.  */
  727.  
  728. template<class charT, class traits, class Allocator>
  729. basic_stringstream<charT, traits, Allocator>::
  730. basic_stringstream(const string_type& s, ios_base::openmode which)
  731. : basic_iostream<charT, traits>( )
  732. , sb_(s, which)
  733. {
  734.   init(&sb_);
  735. }
  736.  
  737. /*
  738.  * virtual ~basic_stringstream()
  739.  */
  740.  
  741. template<class charT, class traits, class Allocator>
  742. basic_stringstream<charT, traits, Allocator>::~basic_stringstream()
  743. {
  744.  
  745. }
  746.  
  747. /*
  748.  * basic_stringbuf *rdbuf() const
  749.  */
  750.  
  751. template<class charT, class traits, class Allocator>
  752. basic_stringbuf<charT, traits, Allocator> *
  753. basic_stringstream<charT, traits, Allocator>::rdbuf() const
  754. {
  755.     return (basic_stringbuf<charT, traits, Allocator> *)&sb_;
  756. }
  757.  
  758. /*
  759.  * basic_string str() const
  760.  */
  761.  
  762. template<class charT, class traits, class Allocator>
  763. basic_string<charT, traits, Allocator>
  764. basic_stringstream<charT, traits, Allocator>::str() const
  765. {
  766.   return sb_.str();
  767. }
  768.  
  769. /*
  770.  * void str(const basic_string& s)
  771.  */
  772.  
  773. template<class charT, class traits, class Allocator>
  774. void basic_stringstream<charT, traits, Allocator>::
  775. str(const string_type& s)
  776. {
  777.   sb_.str(s);
  778. }
  779.  
  780.  
  781. #ifndef _RWSTD_NO_NAMESPACE
  782. }
  783. #endif
  784.  
  785. #pragma option pop
  786. #endif /* __SSTREAM_CC */
  787.